package com.bone;

import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.util.HashMap;

/**
 * 响应对象, 该类的每一个实例用于表示服务端发送给客户端的具体响应内容. 每个响应应该由三部分构成: 1, 状态行 2, 响应头 3, 响应正文
 */
public abstract class HttpResponse {

    // ----------------------- 属性 ---------------------------
    /**
     * 状态行相关信息定义
     */
    private int statusCode;
    private String statusReason;

    /**
     * 响应头相关信息定义
     */
    HashMap<String, String> headers = new HashMap<>();

    /**
     * 响应正文相关信息定义.
     */
    // 请求的抽象路径实体.
    private File entity;

    /**
     * 连接相关信息定义
     */
    private Socket socket;
    private OutputStream os;

    //     ---------------------- 方法 ---------------------------------
    public int getStatusCode() {
        return statusCode;
    }

    public void setStatusCode(int statusCode) {
        this.statusCode = statusCode;
    }

    public String getStatusReason() {
        return statusReason;
    }

    public void setStatusReason(String statusReason) {
        this.statusReason = statusReason;
    }

    public HashMap<String, String> getHeaders() {
        return headers;
    }

    public void setHeaders(HashMap<String, String> headers) {
        this.headers = headers;
    }

    public File getEntity() {
        return entity;
    }

    public void setEntity(File entity) {
        this.entity = entity;
    }

    public Socket getSocket() {
        return socket;
    }

    public void setSocket(Socket socket) {
        this.socket = socket;
    }

    public OutputStream getOs() {
        return os;
    }

    public void setOs(OutputStream os) {
        this.os = os;
    }
//     ------------------ 抽象类 ----------------------

    /**
     * 返回请求
     */
    public abstract void response() throws IOException;


}
